#include "c_interface.h"

int main() {
    // 创建动态数组
    CArray arr = carray_create(10);
    for (int i = 0; i < 100; i++) {
        carray_append(arr, i);
    }
    printf("Array size: %d\n", carray_size(arr));
    
    // 矩阵乘法
    CMatrix mat_a = cmatrix_create(1000, 1000);
    CMatrix mat_b = cmatrix_create(1000, 1000);
    // 填充矩阵数据
    for (int i = 0; i < 1000; i++) {
        for (int j = 0; j < 1000; j++) {
            cmatrix_set(mat_a, i, j, i + j);
            cmatrix_set(mat_b, i, j, i * j);
        }
    }
    
    int error = 0;
    CMatrix result = cmatrix_multiply(mat_a, mat_b, &error);
    if (error) {
        printf("Matrix multiplication failed: %d\n", error);
    }
    
    // 清理资源
    carray_free(arr);
    cmatrix_free(mat_a);
    cmatrix_free(mat_b);
    cmatrix_free(result);
    
    return 0;
}